package servlet;

import org.json.JSONArray;
import service.UserService;
import service.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author lishunlin110
 */
@WebServlet(name = "AddressDelete", value = "/address/delete")
public class AddressDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json; charset=utf-8");
        String id = request.getParameter("id");
        PrintWriter out = response.getWriter();
        UserService service = new UserServiceImpl();
        try {
           int result = service.deleteAddress(Integer.parseInt(id));
           if(result!=0){
               out.println("T");
           }else {
               out.println("F");
           }
        } catch (Exception e) {
            e.printStackTrace();
            out.println("E");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
